import java.awt.event.HierarchyBoundsAdapter;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 23735
 * Date: 2023-11-12
 * Time: 23:38
 */
public class Solution {
    /**
     *  二分查找
     *  注意 数值与下标是正好对应的这个条件, 正好利用这个条件
     */
    public int takeAttendance(int[] records) {
        int len = records.length;
        int left = 0;
        int right = len;
        while (left < right) {
            int mid = ((right-left) >> 1) + left;
            if (records[mid] == mid) {
                left = mid + 1;
            } else {
                right = mid;
            }
        }
        return left;
    }
}
